﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using GPSMap.Core.Misc.DAL;
using HTMapLib;
using HTMapLib.Classes;
using MapControl;
using MapControl.Misc;
using MapControl.Misc.DAL;

namespace GPSMap
{
    public partial class frmGPSInfo : Form
    {
        private frmGPSTracking _formMain;

        public frmGPSInfo(frmGPSTracking frm)
        {
            InitializeComponent();
            _formMain = frm;
        }

        public void ShowInfo(BaseGPSPoint gpsPoint)
        {
            GPSData objGPSData = gpsPoint.objGPSData;
            PlaneRepository objPlaneRepository = new PlaneRepository();

            txtName.Text = objPlaneRepository.GetPlaneName(objGPSData.Name);
            txtLon.Text = HTCollectionHelper.DecimalToDMS(objGPSData.LonGPS);
            txtLat.Text = HTCollectionHelper.DecimalToDMS(objGPSData.LatGPS);
            txtAlt.Text = objGPSData.Alt.ToString();
            txtSpeed.Text = objGPSData.Speed.ToString();
            txtAngle.Text = objGPSData.Angle.ToString();
            txtTime.Text = objGPSData.Time.ToString("HH:mm:ss");
            txtSatNum.Text = objGPSData.SatNum.ToString("0#");

            double angle, distance;
            angle = distance = 0;
            _formMain.CalPVCL(gpsPoint.objGPSData.LonGPS, gpsPoint.objGPSData.LatGPS, ref angle, ref distance);
            lblPVCL.Text = string.Format("Phương vị - Cự ly ( theo sân bay {0} )",
                                         GeneralClass.objCurrAirport.Airport_Name);
            txtPhuongVi.Text = angle.ToString("#");
            
            if (distance > 100)
                txtCuLy.Text = distance.ToString("#");
            else
                txtCuLy.Text = distance.ToString("0.#");
        }

        private void frmGPSInfo_Load(object sender, EventArgs e)
        {

        }

        private void frmGPSInfo_FormClosing(object sender, FormClosingEventArgs e)
        {
            //formMain.ShowGPSInfo(false);
            //this.C;
        }
    }
}